<?php
/**
 * Created By Project
 * Author: 陈东
 * Copyright：陈东
 * Source Code：陈东
 * Explain：I shall not authorize for any other commercial purposes, law breakers must be prosecuted.
 */
namespace Live\Controller;
use Think\Controller;

class TalkController extends BaseController{

    /*
     * 写入聊天记录
     */
    public function writef(){
		$talkContent = html_entity_decode(I('post.talk'));
//		$fpath = $this->getFilePath();
//		$fh = fopen($fpath, "w");
//		fwrite($fh, $talkContent);
//		fclose($fh);
		//写入缓存
		S('live_talk_file',$talkContent);
    }

	/*
     * 读取聊天记录
     */
	public function readf(){
//		$fpath = $this->getFilePath();
//		$data = file_get_contents($fpath);
//		$result = trim($data, "\xEF\xBB\xBF");

		//读取缓存
		$result = S('live_talk_file');
		echo $result;
	}

	/*
	 * 获取文件路径
	 */
	protected function getFilePath(){
		$f = C('TALKFILEPATH');
		$fname = ".".$f.C('TALKFILENAME');
		return $fname;
	}


}